package de.zefania.api.builder;

import java.io.File;
import java.util.HashMap;

import de.zefania.api.BibleBook;
import de.zefania.api.BibleModul;
import de.zefania.api.Chapter;
import de.zefania.api.ModulInformation;
import de.zefania.api.Position;
import de.zefania.api.Prolog;
import de.zefania.api.Vers;

/**
 * abstract class that offers methods to build a bible modul and save it to the hard disk
 * @author Thomas
 *
 */
public abstract class BibleBuilder {
	public enum ModulStatus { v, w }
	public enum ModulType { BIBLE,  QURAN, OTHER, CULT, COMMENTARY, PARALLEL }
	public enum ModulContent { CATHOLIC, PROTESTANT, OTHER, ADDON }
		
	
	protected BibleModul modul;
	protected File file;
	
	/**
	 * creates an empty valid Zefania XML Modul
	 * @param file - the file where the modul will be stored in
	 */
	public abstract void createEmptyModul(File file);
	
	/**
	 * sets the name of the bible
	 * @param bibleName
	 */
	public abstract void setBibleName(String bibleName);
	
	/**
	 * sets the revision number of the modul (not the translation) 
	 * @param revision
	 */
	public abstract void setRevision(int revision);
	
	/**
	 * sets the status of the modul
	 * @param status
	 */
	public abstract void setStatus(ModulStatus status);
	
	/**
	 * sets the type of the modul (bible or any other book).
	 * <p>
	 * note that most bible programms will have problems 
	 * with moduls that have a different structure than the bible
	 * 
	 * @param type
	 */
	public abstract void setType(ModulType type);
	
	/**
	 * sets the content of the bible
	 * @param content
	 */
	public abstract void setContent(ModulContent content);
	
	/**
	 * set the location of the schema definition (Standard: "zef2005.xsd")
	 * @param schemaLocation
	 */
	public abstract void setSchemaLocation(String schemaLocation);
	
	/**
	 * sets the version of the schema definition
	 * @param schemaVersion
	 */
	public abstract void setSchemaVersion(String schemaVersion);
	
	/**
	 * sets the children of the &lt;INFORMATION&gt;-Element
	 * @param information
	 */
	public abstract void setInformation(HashMap<String, String[]> information);
	
	/**
	 * sets the children of the &lt;INFORMATION&gt;-Element
	 * @param information
	 */
	public abstract void setInformation(ModulInformation information);
	
	/**
	 * sets information for bible software developer
	 * @param appinfo
	 */
	public abstract void setAppInfo(String appinfo);
	
	/**
	 * appends a complete BibleBook to the modul
	 * @param book
	 */
	public abstract void appendBibleBook(BibleBook book);
	
	/**
	 * appends an empty BibleBook-Element to the modul
	 * @param bname - the name of the book
	 * @param shortName - the abbrevation of the bookname
	 * @param bnumber - the number of the book
	 */
	public abstract void appendEmptyBibleBook(String bname, String shortName, int bnumber);
	
	/**
	 * appends an empty BibleBook-Element to the modul.
	 * <p>
	 * the booknumber is set automatically (the highest number in the modul + 1)
	 * @param bname - the name of the book
	 * @param shortName - the abbrevation of the bookname	 
	 */
	public abstract void appendEmptyBibleBook(String bname, String shortName);
	
	/**
	 * appends a complete Chapter to the modul
	 * @param chapter
	 */
	public abstract void appendChapter(Chapter chapter);
	
	/**
	 * appends an empty Chapter-Element to the modul
	 * @param bnumber
	 * @param cnumber
	 */
	public abstract void appendEmptyChapter(int bnumber, int cnumber);
	
	/**
	 * appends a Prolog to the modul, the position is specified in the Prolog object itself
	 * @param prolog	 
	 */
	public abstract void appendProlog(Prolog prolog);
	
	/**
	 * appends a Prolog to a bible book 
	 * @param bnumber the number of the bible book
	 * @param text the text content of the prolog
	 */
	public abstract void appendProlog(int bnumber, String text);
	
	/**
	 * appends a Prolog to a chapter
	 * @param bnumber the number of the bible book
	 * @param cnumber the number of the chapter
	 * @param text the text content of the prolog
	 */
	public abstract void appendProlog(int bnumber, int cnumber, String text);
	
	/**
	 * appends a single vers to the modul
	 * <p>
	 * the position is taken from the Vers object itself
	 * @param vers
	 */	
	public abstract void appendVers(Vers vers);
	
	/**
	 * appends a single vers to the modul
	 * @param pos the position of the vers
	 * @param text
	 */
	public abstract void appendVers(Position pos, String text);
	
	/**
	 * appends a reference to another vers/bibletext to the modul
	 * @param from the position the link has to be inserted
	 * @param to the position the link leads to
	 */	
	public abstract void appendReference(Position from, Position to);
	
	/**
	 * appends a reference to another vers/bibletext to the modul
	 * @param from the position the link has to be inserted
	 * @param to the position the link leads to
	 * @param title an optional title of the link
	 */	
	public abstract void appendReference(Position from, Position to, String title);
	
	/**
	 * appends a remark to the modul
	 * @param pos the position of the bible text the remarks refers to
	 * @param remark
	 */
	public abstract void appendRemark(Position pos, String remark);
	
	/**
	 * returns the built BibleModul
	 * @return
	 */
	public final BibleModul getModul() {
		return modul;
	}
	
	/**
	 * saves the created modul to the hard disk
	 */
	public abstract void saveToDisk();
	
}
